extends Node2D

@export var node_史莱姆节点 : PackedScene
@export var node_击杀数 : Label
var label_击杀数 : int = 0
@export var node_关卡数 : Label
var label_关卡数 : int = 0
@export var timer_史莱姆刷新速度 : Timer

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
	node_击杀数.text = '击杀: ' + str(label_击杀数)
	label_关卡数 = int(label_击杀数 / 10.0) + 1
	node_关卡数.text = '关卡: ' + str(label_关卡数)
	pass

func _on_timer_生成史莱姆_timeout() -> void:
	var node_史莱姆实例 : Area2D = node_史莱姆节点.instantiate()
	node_史莱姆实例.position = Vector2(260, randi_range(46, 120))
	# 判断关卡 增加史莱姆移动速度
	node_史莱姆实例.speed_史莱姆速度 = -50 + (-10 * (label_关卡数 - 1))
	# 判断关卡 增加史莱姆刷新速度
	timer_史莱姆刷新速度.wait_time = 3 - (0.2 * (label_关卡数 - 1))
	get_tree().current_scene.add_child(node_史莱姆实例)
	pass # Replace with function body.
